package com.mrzhou.auth.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * OAuth2.0资源服务器配置
 */
@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        // 无需进行安全验证的uri
        String[] excludePath = new String[]{"/actuator/**", "/token/**", "/mobile/**", "/v2/api-docs", "/v2/api-docs-ext", "/user/logout", "/user/get-image-code"};

        http.headers().frameOptions().disable();
        http.formLogin()
                .and()
                .authorizeRequests()
                .antMatchers(excludePath)
                .permitAll()
                .anyRequest().authenticated()
                .and().csrf().disable();
    }



}
